<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class jQuickForm_Element_TimePicker extends HTML_QuickForm2_Element_InputText {
    public function render(HTML_QuickForm2_Renderer $renderer){
        jQuickForm::js()->needJquery();
        jQuickForm::js()->needJqueryUi();
        jQuickForm::js()->addJs('/vendors/jquery/ui/jquery.datetimepicker.js');
        jQuickForm::js()->addJsOnload('
jQuery("#'.$this->getId().'").timepicker({
        showSecond: '.($this->timepicker_show_second ? 'true':'false').',
        timeFormat: "'.$this->timepicker_time_format.'",
        stepHour: '.$this->timepicker_step_hour.',
        stepMinute: '.$this->timepicker_step_minute.',
        stepSecond: '.$this->timepicker_step_second.',
        hourMin: '.$this->timepicker_hour_min.',
        currentText: "Сейчас",
        hourMax: '.$this->timepicker_hour_max.',
        closeText:"Готово",
        timeOnlyTitle: "Выберите время",
        timeText: "Время",
        hourText: "Часы",
        minuteText: "Минуты",
        secondText: "Секунды",
        dateFormat: "dd.mm.yy",
        monthNames: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
        monthNamesShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
        dayNamesMin: ["Пн", "Вт", "Ср", "Чт","Пт","Сб","Вс"]
    });
');
        return parent::render($renderer);
    }



    protected $timepicker_hour_max   = 23;
    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setHourMax($value=1){
        $this->timepicker_hour_max = $value;
        return $this;
    }



    protected $timepicker_hour_min   = 0;
    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setHourMin($value=1){
        $this->timepicker_hour_min = $value;
        return $this;
    }



    protected $timepicker_step_hour   = 1;
    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setStepHour($value=1){
        $this->timepicker_step_hour = $value;
        return $this;
    }



    protected $timepicker_step_minute = 1;
    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setStepMinute($value=1){
        $this->timepicker_step_minute = $value;
        return $this;
    }



    protected $timepicker_step_second = 1;
    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setStepSecond($value=1){
        $this->timepicker_step_second = $value;
        return $this;
    }

    protected $timepicker_show_second = true;

    /**
     * @return jQuickForm_Element_TimePicker
     */
    function setShowSecond($value=1){
        $this->timepicker_show_second = (bool)$value;
        if($value){
            $this->timepicker_time_format = "hh:mm:ss";
        } else {
            $this->timepicker_time_format = "hh:mm";
        }
        return $this;
    }


    protected $timepicker_time_format= "hh:mm:ss";

}
?>